﻿using System;
using System.Collections.Generic;
using System.Text;

using ZoneFiveSoftware.Common.Data.Fitness;
using ZoneFiveSoftware.Common.Visuals.Fitness;
using SportTracksSwimSetPlugin.Edit;

using SportTracksSwimSetPlugin.Common;

namespace SportTracksSwimSetPlugin
{
    class SwimSetDataImporters : IExtendDataImporters
    {
        public void AfterImport(System.Collections.IList added, System.Collections.IList updated)
        {
            //foreach (object addElement in added)
            //{
            //    if (addElement is IActivity)
            //    {
            //        IActivity addActivity = (IActivity) addElement;
            //        if (addActivity.Category.ToString().ToLower().Contains("swim"))
            //        {
            //            SwimSetWorker addSwimSet = new SwimSetWorker(addActivity);
            //            addSwimSet.addSwimDistance();
            //        }
            //    }
            //}
        }

        public void BeforeImport(System.Collections.IList items)
        {
            foreach (object addElement in items)
            {
                if (addElement is IActivity)
                {
                    IActivity addActivity = (IActivity)addElement;
                    if ( SwimSetSettings.CategoryList.Contains(addActivity.Category.ReferenceId) 
                         && addActivity.DistanceMetersTrack == null
                         && addActivity.TotalDistanceMetersEntered == 0 )
                    {
                        SwimSetWorker addSwimSet = new SwimSetWorker(addActivity);
                        addSwimSet.addSwimDistance();
                    }
                }
            }
        }

        public IList<IFileImporter> FileImporters
        {
            get { return null; }
        }
    }
}
